package com.lzy.cloud.ticket.train.job;

import com.lzy.cloud.ticket.train.facade.StationFacade;
import com.lzy.cloud.ticket.train.response.TrainCodeResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by WIN7 on 2018/6/1.
 */
@Slf4j
@Component
public class TrainStationInfo {

    @Autowired
    private StationFacade stationFacade;


    @Scheduled(cron = "0 0 0 1/1 * ? ")
    private void trainStationInfo() {
        TrainCodeResponse trainCodeResponse = stationFacade.queryStationList();
        if(trainCodeResponse.getData()!=null){
            stationFacade.deleteTrainStationTable();
            stationFacade.batchInsertTrainCode(trainCodeResponse.getData());

        }
        log.info(trainCodeResponse.toString());
    }


}
